home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Microsoft Internet Strate…Tools for the Enterprise
/
Microsoft Internet Strategy & Tools for the Enterprise.iso
/
content
/
devel.tls
/
icp
/
vbsamp
/
qukmail.exe
/
MAILFCNS.BAS
< prev
Wrap
BASIC Source File
|
1996-03-07
|
9KB
|
190 lines
Attribute VB_Name = "MailFunctions"
Option Explicit
'-------------------------------------------------------
Public Function ParseMessage(msg As String, Group As String, Alias As String) As Boolean
'-------------------------------------------------------
Dim strStart As Long
Dim strEnd As Long
Dim Body As String
'-------------------------------------------------------
strStart = InStr(1, msg, vbCrLf & vbCrLf & vbCrLf) + 6
If (strStart > 6) Then
strEnd = InStr(strStart, msg, vbCrLf & "." & vbCrLf) + 1
If (strEnd > 0) Then
Body = Mid(msg, strStart, strEnd - strStart + 1)
strEnd = InStr(1, Body, vbCrLf) - 1
If (strEnd > 0) Then
Group = Mid(Body, 1, strEnd)
strStart = strEnd + 3
strEnd = InStr(strStart, Body, vbCrLf) - 1
If (strEnd > 0) Then
Alias = Mid(Body, strStart, strEnd - strStart + 1)
ParseMessage = True
End If
End If
End If
End If
'-------------------------------------------------------
End Function
'-------------------------------------------------------
'-------------------------------------------------------
Public Function BuildDatabase(NewDbName As String, ParamArray ObjScripts() As Variant) As Boolean
'-------------------------------------------------------
Dim DB As Database ' Database
Dim RS As Recordset ' Record set
Dim SQL As Long ' ObjScripts index variable
'-------------------------------------------------------
If (Dir(NewDbName) <> "") Then Exit Function ' Database already exists Exit
On Error GoTo CleanUp ' Handle errors...
Screen.MousePointer = vbHourglass
Set DB = CreateDatabase(NewDbName, dbLangGeneral, dbVersion30) ' Create new database
For SQL = LBound(ObjScripts) To UBound(ObjScripts) ' For each sql script parameter
DB.Execute ObjScripts(SQL), dbSQLPassThrough ' Execute sql script
Next ' Next parameter
'-------------------------------------------------------
CleanUp: ' Clean up workspace...
'-------------------------------------------------------
If Not (DB Is Nothing) Then DB.Close ' Close database connection
Set DB = Nothing ' Destory db object
Screen.MousePointer = vbDefault
'-------------------------------------------------------
End Function
'-------------------------------------------------------
'-------------------------------------------------------
Public Sub AddAliasToDatabase(DBName As String, Group As String, Alias As String)
'-------------------------------------------------------
Dim DB As Database ' Database
Dim RS As Recordset ' Record set
'-------------------------------------------------------
Screen.MousePointer = vbHourglass
On Error Resume Next ' Handle error in case Group already exists...
Set DB = OpenDatabase(DBName)
Set RS = DB.OpenRecordset("addresses", dbOpenTable) ' Open recordset...
With RS
.AddNew ' Insert new record
.Fields("groupname") = Group ' Add Group
.Fields("alias") = "" '
.Update ' Save changes.
.AddNew ' Insert new record
.Fields("groupname") = Group ' Add Group
.Fields("alias") = Alias ' Add Alias
.Update ' Save changes.
End With
RS.Close ' Close record set
Set RS = Nothing ' Destroy record set object
DB.Close ' Close database connection
Set DB = Nothing ' Destory db object
Screen.MousePointer = vbDefault
'-------------------------------------------------------
End Sub
'-------------------------------------------------------
'-------------------------------------------------------
Public Sub AddAliasesToTree(Tree As TreeView, DBName As String)
'-------------------------------------------------------
Dim DB As Database ' Database
Dim RS As Recordset ' Record set
'-------------------------------------------------------
Screen.MousePointer = vbHourglass
On Error Resume Next ' Handle error in case Group already exists...
Set DB = OpenDatabase(DBName)
Set RS = DB.OpenRecordset("addresses", dbOpenTable) ' Open recordset...
With RS
Do While Not .EOF
Call AddAliasToTree(Tree, .Fields("groupname"), .Fields("alias"))
.MoveNext
Loop
End With
RS.Close ' Close record set
Set RS = Nothing ' Destroy record set object
DB.Close ' Close database connection
Set DB = Nothing ' Destory db object
Screen.MousePointer = vbDefault
'-------------------------------------------------------
End Sub
'-------------------------------------------------------
'-------------------------------------------------------
Public Sub AddAliasToTree(Tree As TreeView, Group As String, Alias As String)
'-------------------------------------------------------
Dim NodeR As Node
Dim NodeP As Node
Dim NodeC As Node
'-------------------------------------------------------
With Tree
Set NodeR = .Nodes(1) ' Grab root node...
On Error Resume Next ' Handle duplicate name entries...
Set NodeP = .Nodes(Group)
If (NodeP Is Nothing) Then
Set NodeP = .Nodes.Add(NodeR, tvwChild, Group, Group, icoGROUP)
End If
If (Alias <> "") Then
Set NodeC = .Nodes(Group & Alias)
If (NodeC Is Nothing) Then
Set NodeC = .Nodes.Add(NodeP, tvwChild, Group & Alias, Alias, icoALIAS)
End If
End If
End With
'-------------------------------------------------------
End Sub
'-------------------------------------------------------
'-------------------------------------------------------
Public Sub DeleteAliases(Tree As TreeView, DBName As String)
'-------------------------------------------------------
Dim DB As Database ' Database
Dim RS As Recordset ' Record set
Dim Group As String ' Email Group
Dim Alias As String ' Email Alias
Dim NodeC As Node ' Current node
'-------------------------------------------------------
Set NodeC = Tree.SelectedItem
Group = NodeC.Key ' Get Node Key[groupname or groupname\alias]
Alias = NodeC.Text ' Get Node Text[groupname or alias]
If (Group = "") Or (Group = MAILGROUPROOT) Then Exit Sub ' Valdiate node key
Screen.MousePointer = vbHourglass
'-------------------------------------------------------
' Delete group\alias from database
'-------------------------------------------------------
Set DB = OpenDatabase(DBName) ' Open database
If (Group = Alias) Then ' Node is group
' Delete group from database
DB.Execute "delete * from addresses where groupname = """ & Group & """"
Tree.Nodes.Remove Group ' Delete group/s from tree...
Else ' Node is alias only
Group = NodeC.Parent.Text
' Delete alias from database
DB.Execute "delete * from addresses where alias = """ & Alias & """" & _
" and groupname = """ & Group & """"
Tree.Nodes.Remove Group & Alias ' Delete alias from tree...
End If
DB.Close ' Close database connection
Set DB = Nothing ' Destory db object
Screen.MousePointer = vbDefault
'-------------------------------------------------------
End Sub
'-------------------------------------------------------